// bsp2.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>

const float PI = 3.1415;

void kreis(float, double*, double*);
void nl();
void star();
void blank();
void ntimes(int, void (*foo)());

int main(int argc, char* argv[])
{
	double *a = (double *)malloc(sizeof(double));
	double *c = (double *)malloc(sizeof(double));
	

	ntimes(49, star);
	nl();


	star();
	ntimes(4, blank);
	printf("Radius\t");
	star();
	ntimes(4, blank);
	printf("Umfang\t");
	star();
	ntimes(4, blank);
	printf("Flaeche\t");
	star();


	nl();	
	ntimes(49, star);
	nl();

	for(float r = 0.5; r <= 10; r += 0.5)
	{
		kreis(r, a, c);
		star();
		ntimes(5, blank);
		printf("%.1f\t", r);
		star();
		ntimes(5, blank);
		printf("%3.2f\t", *a);
		star();
		ntimes(5, blank);
		printf("%3.2f\t", *c);
		star();
		nl();
	}
	ntimes(49, star);
	getchar();
}

void kreis(float radius, double *area, double *circfr)
{
	*circfr = 2*PI*radius;
	*area = radius*radius*PI;
}

//-------------------------------------------------------------
// Beispiel 3
//-------------------------------------------------------------
void nl()
{
	printf("\n");
}

void star()
{
	printf("*");
}

void blank()
{
	printf(" ");
}

void ntimes(int number, void (*foo)())
{
	for(int i = 0; i < number; i++)
	{
		(*foo)();
	}
}
